package com.base.study.presenter;

import android.app.Activity;

import com.base.commonlib.base.presenter.BasePresenter;
import com.base.commonlib.http.RealNetWorkUtil;
import com.base.commonlib.http.utils.CallBackImpl;
import com.base.study.bean.OnlineStudyListBean;
import com.base.study.bean.OnlineStudySecondListBean;
import com.base.study.bean.OnlineStudyTreeBean;
import com.base.study.bean.OnlineStydyFirstListBean;
import com.base.study.bean.ScopeBean;
import com.base.study.view.MyStudyListView;
import com.base.study.view.OnclineStudyFirstListView;
import com.base.study.view.OnlineStudyListView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.disposables.Disposable;

/**
 * Created by zw on 2020/2/21.
 */

public class OnlineStudyFirstListPresenter extends BasePresenter<OnclineStudyFirstListView> {
    public OnlineStudyFirstListPresenter(OnclineStudyFirstListView view, Activity activity) {
        super(view, activity);
    }

    public void getList1(){
        Disposable enqueue = RealNetWorkUtil.get().method("api-train/category/listFirst").addParams("","")
                .build().enqueueForArray(OnlineStydyFirstListBean.class, new CallBackImpl<List<OnlineStydyFirstListBean>>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        //mView.showError();
                        mView.returnError();
                    }

                    @Override
                    public void onNext(List<OnlineStydyFirstListBean> list) {
                        mView.returnList(list);
                    }
                });

        mCompositeDisposable.add(enqueue);
    }
    public void getList(){
        mView.showPb();
        Disposable enqueue = RealNetWorkUtil.get().method("api-train/category/tree").addParams("","")
                .build().enqueueForArray(OnlineStudyTreeBean.class, new CallBackImpl<List<OnlineStudyTreeBean>>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb();
                        mView.showError();
                        mView.returnError();
                    }

                    @Override
                    public void onNext(List<OnlineStudyTreeBean> list) {
                        mView.hidePb();
                        mView.returnTreenList(list);
                    }
                });

        mCompositeDisposable.add(enqueue);
    }



    public void getRightList(String id){
        Disposable enqueue = RealNetWorkUtil.get().method("api-train/category/listSecond").addParams("id",id)
                .build().enqueueForArray(OnlineStudySecondListBean.class, new CallBackImpl<List<OnlineStudySecondListBean>>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.showError();
                        mView.returnError();
                    }

                    @Override
                    public void onNext(List<OnlineStudySecondListBean> list) {
                        mView.returnRightList(list);
                    }
                });

        mCompositeDisposable.add(enqueue);
    }
}
